home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
tutor
/
dosguide.exe
/
HELPDOS.ZIP
/
IF.HLP
< prev
next >
Wrap
Text File
|
1985-09-03
|
2KB
|
47 lines
---------------------- IF - Internal Batch Subcommand ------------------------
IF allows conditional execution of lines in a Batch File. This allows control
of the order of execution of lines based on a true/false condition.
FORMAT: IF [NOT] condition command
REMARKS:
"condition" may be one of the following:
string1==string2 - specifies that if "string1" is identical to
"string2" (including upper and lower case
letters), then "condition" is true.
ERRORLEVEL number - specifies that if the exit code of the previously
run program is "number" or higher, then
"condition" is true.
EXIST filespec - specifies that if the file named in "filespec"
exists, then "condition" is true. Path names are
not allowed in "filespec." Global characters
(* and ?) are allowed.
command - a command for DOS to execute.
NOT - specifies that "command" is to be executed if "condition" is
false.
When the IF "condition" is true (false, if NOT is specified) then "command"
is executed. Otherwise, "command" is ignored and the following line of the
batch file is executed.
EXAMPLE:
In this example, the replaceable parameter, %1, represents the name of a file.
If the file is found on the specified drive, then the IF "condition" is true and
"GOTO PRINT" will be executed. If the file is not found, "GOTO PRINT" will be
ignored and the next line "REM File %1 not found" will be executed.
REM Print the File if it exists
IF EXIST %1 GOTO PRINT
REM File %1 not found
GOTO END
:PRINT
PRINT %1
:END
REM End of Batch File